<?php
/**
 * 缺货登记
 * User: ws
 * Date: 2018/9/3
 * Time: 15:24
 */

namespace app\admin\controller;

use think\Db;
class Shortage  extends Init
{
    function index(){
        if ($this->request->isAjax()) {
            $key = input('key')?input('key'):'';
            $where['u.name|g.name|content'] = array('like','%'.trim($key).'%');

            $list = Db::table('je_shortage_goods')
                ->alias('s')
                ->join('je_user u','s.user_id = u.user_id')
                ->join('je_goods g','s.goods_id = g.goods_id')
                ->field('u.name as uname,g.name as gname,s.*')
                ->where($where)->order('shortage_id desc')
                ->paginate(input('limit'))->toArray();

            return json($result = ['code'=>0,'msg'=>'获取成功','data'=>$list['data'],'count'=>$list['total']]);
        }
        return view('list');
    }
}